classdef Conductivity < Processor
  % Class for calculating Conductivity ala SBE Data Procesing
  % Derived from Processor
  % Constructor signature: C = Conductivity(data, conn, P, T), 
  %     all args. optional
  %
  % Author: David Goldsmith, Wash. State Dept. of Ecology, dgol461@ecy.wa.gov
  % Release date: N/A
  
    properties
      % inherited from Processor
%         inData;
%         castDT;
%         scanRate;
%         ParamID;
%         ParamDesc;
%         SBEprec;
%         EquipID;
        DBdata;
        outData;
    end
    
    methods
        function C = Conductivity(data, conn, P, T) % Constructor
            if nargin < 1, data = []; end
            if nargin < 2, conn = []; end
            if nargin < 3, P = []; end
            if nargin < 4, T = []; end
            
            C = C@Processor(data);
            if ~isempty(conn), C.getDBdata(conn, 'C'); end
            if nargin==4, C.mainFormula(P, T); end
        end
        
        function delete(obj) % Destructor
            % Here in case I need it
        end
        
        function mainFormula(obj, P, T)
            tmp = obj.inData.Sensors.ConductivitySensor;
            f = 1e-3 * obj.inData.Cf; % Cf comes in as Hz, but needs to be in kHz
            d = tmp.CTcor; e = tmp.CPcor; 
            g = tmp.G; h = tmp.H; i = tmp.I; j = tmp.J;
            fsq = f.^2; 
            obj.outData = (g + h*fsq + i*f.*fsq + j*fsq.*fsq) ./ (1 + d*T + e*P);
        end
        
    end
    
end